package org.springframework.study;

import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.study.ignore.Admin;
import org.springframework.study.ignore.Person;
import org.springframework.study.ignore.UserAware;

@SuppressWarnings("deprecation")
public class IgnoreTest {

	public static void main(String[] args) {
		XmlBeanFactory bf = new XmlBeanFactory(new ClassPathResource("ignore.xml"));
		// bf.ignoreDependencyInterface(UserAware.class);
		bf.ignoreDependencyType(Admin.class);

		Person person = bf.getBean("person", Person.class);
		System.out.println("person ---> " + person);
		System.out.println("person.user ---> " + person.getUser());
		System.out.println("person.admin ---> " + person.getAdmin());
	}

	// Spring中之所以要忽略BeanNameAware,BeanFactoryAware等接口实现类的属性自动注入
	// 是因为Spring会通过回调这些接口的set方法设置属性值

	//1.ignoreDependencyInterface(UserService.Class)
	//  接口UserService，UserServiceImpl实现UserService，UserServiceImpl忽略自动注入和UserService中的setter方法入参相同的类
	//2.ignoreDependencyType(XX.Class)
	//  忽略自动注入传入XX.Class的类型
	// 这样来看ignoreDependencyType方法的生效范围更广

}
